#include <stdlib.h>
#include <fcntl.h>
#include "interpose.h"

static int count_malloc = 0;
static int count_free = 0;

static void *
my_malloc(size_t size)
{
	count_malloc++;
	return malloc(size);
}

static void
my_free(void *ptr)
{
	count_free++;
	free(ptr);
}

static void
my_exit(int status)
{
	printf("Number of malloc() calls = %d\n", count_malloc);
	printf("Number of free() calls = %d\n", count_free);
	exit(status);
}

DYLD_INTERPOSE(my_malloc, malloc)
DYLD_INTERPOSE(my_free, free)
DYLD_INTERPOSE(my_exit, exit)
